﻿using Teamwish.Domain.BLL;
using Teamwish.Domain.Models;
using Ninject;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.SessionState;

namespace Teamwish.WebUI.Common
{
    public class NinjectControllerFactory : DefaultControllerFactory
    {
        private IKernel kernel;
        public NinjectControllerFactory()
        {
            kernel = new StandardKernel();
            AddBindings();

        }
        private void AddBindings()
        {
            kernel.Bind<EfDbContext>().ToSelf().InScope(x=>HttpContext.Current);
            //kernel.Bind<UserinfoService>().ToSelf();
            //kernel.Bind<UserinfoDetailService>().ToSelf();

        }

        protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
        {

            return controllerType == null ? null : (IController)kernel.Get(controllerType);
        }
    }
}